home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 615 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: brahms.tfi.be!usenet
  2. From: Tasmaniac@unicall.be (Tasmaniac)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Pascal program works but not C program!
  5. Date: Sun, 07 Jan 1996 18:29:49 GMT
  6. Organization: ACiD
  7. Message-ID: <4cp3vc$8nh@brahms.tfi.be>
  8. References: <4cdpr2$psi@lugb.latrobe.edu.au>  <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il>
  9. NNTP-Posting-Host: 193.210.154.87
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. >> Why does the Pascal version of this program behave exactly as expected while the
  13. >> C++ version does not?
  14. let's have a look...
  15.  
  16. >>    while ((y<=height) && (!empty(posptr->next)))
  17. >>    {
  18. >>         gotoxy(1,y);
  19. >>         strcpy(line_,posptr->line);
  20. >>         line__=&(line_[stringpos]);
  21. >>         strncpy(line,line__,width-1);
  22. This isn't valid, you can't 'strncpy' single characters to a string.
  23. It SHOULD give you a warning on that.
  24.  
  25. >>         strcat(line,null);
  26. >                       ^---------------This is a problem!!!!!!!!!
  27. No, it was probably already wrong on the previous line. 
  28.  
  29. >> void main(int argc,char *argv[])
  30. >   ^-----------------------------This one too, but not too serious
  31. why is this a problem ?
  32.  
  33. >Another problem, not as serious as the previous one, although this is not
  34. >the reason the C++ version might not work; main() should be defined
  35. >returning int, not void. 
  36. It's 100% legal to declare main as any of the following
  37.  
  38. void main (void)
  39. int main (void)
  40. void main (int argc, char *argv[])
  41. int main (int argc, char *argv[])
  42. void main (int argc, char **argv)
  43. int main (int argc, char **argv)
  44. void main (int argc, char *argv[], char *envp[])
  45. int main (int argc, char *argv[], char *envp[])
  46. void main (int argc, char *argv[], char **envp)
  47. int main (int argc, char *argv[], char **envp)
  48. void main (int argc, char **argv, char *envp[])
  49. int main (int argc, char **argv, char *envp[])
  50. void main (int argc, char **argv, char **envp)
  51. int main (int argc, char **argv, char **envp)
  52.  
  53. erhm..  that should be it, I may have missed one...
  54.  
  55.  
  56.  
  57.